路径数据(PathData)
PathData 是 PathCommand 的可索引集合。
Path 与 PathData 都可像数组一样通过 ipairs 迭代命令。
方法(Methods)
__len
每个条目都是描述路径段或动作的 PathCommand。
for i, command in ipairs(pathData) do
print(i, command.type)
end
返回路径命令数量。
local count = #pathData
print(count)
contours
返回首个轮廓的 ContourMeasure。
轮廓是从 moveTo 开始,到下一次 moveTo(或路径结束)前的路径片段序列。
可通过返回对象的 next 遍历后续轮廓。若无轮廓返回 nil。
local contour = pathData:contours()
while contour do
print(contour.length)
contour = contour.next
end
measure
返回测量整条路径(所有轮廓)的 PathMeasure。
可获取总长度并执行整体路径操作。
local measure = pathData:measure()
print(measure.length)